//
//  JXStatusBottomView.swift
//  01-weiboSwift
//
//  Created by TwistFate on 16/3/3.
//  Copyright © 2016年 TwistFate. All rights reserved.
//

import UIKit

class JXStatusBottomView: UIView {

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = UIColor(white: 255 / 255.0, alpha: 1)
        
        prepareUI()
    }
    
    private func prepareUI() {
        // 添加子控件
        addSubview(forwardButton)
        addSubview(commentButton)
        addSubview(likeButton)
        addSubview(separatorViewFirst)
        addSubview(separatorViewSecond)
        
        // 添加约束
        // 按钮平铺
        let multipliedBy = 1 / 3.0
        // 转发
        forwardButton.snp_makeConstraints { (make) -> Void in
            make.leading.top.bottom.equalTo(self)
            make.width.equalTo(self).multipliedBy(multipliedBy)
        }
        
        // 评论
        commentButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(forwardButton.snp_trailing)
            make.top.bottom.equalTo(self)
            make.width.equalTo(self).multipliedBy(multipliedBy)
        }
        
        // 赞
        likeButton.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(commentButton.snp_trailing)
            make.top.trailing.bottom.equalTo(self)
            make.width.equalTo(self).multipliedBy(multipliedBy)
        }
        
        // 分割线1
        separatorViewFirst.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(forwardButton.snp_trailing)
            make.centerY.equalTo(forwardButton)
            make.width.equalTo(1)
        }
        
        // 分割线2
        separatorViewSecond.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(commentButton.snp_trailing)
            make.centerY.equalTo(commentButton)
            make.width.equalTo(1)
        }
    }

    
    lazy var forwardButton : UIButton = UIButton(imageName: "timeline_icon_retweet", bkgImageName: "timeline_card_bottom_background", title: "转发")
    
    lazy var commentButton : UIButton = UIButton(imageName: "timeline_icon_comment", bkgImageName: "timeline_card_bottom_background", title: "评论")
    
    lazy var likeButton : UIButton = UIButton(imageName: "timeline_icon_comment", bkgImageName: "timeline_card_bottom_background", title: "赞")
    
    // 分割线1
    private lazy var separatorViewFirst: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
    
    private lazy var separatorViewSecond: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
}
